<template>
  <section>
    <el-table :data="resumeList">
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column label="姓名">
        <template slot-scope="scope">
          {{scope.row.name}}
        </template>
      </el-table-column>
      <el-table-column label="性别">
        <template slot-scope="scope">
          <span v-if="scope.row.sex === 'Male'">男</span>
          <span v-if="scope.row.sex === 'Female'">女</span>
        </template>
      </el-table-column>
      <el-table-column label="生日">
        <template slot-scope="scope">
          {{scope.row.birthday}}
        </template>
      </el-table-column>
      <el-table-column label="检测时间">
        <template slot-scope="scope">
          {{scope.row.col13}}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="loadingDMS(scope.row)">选择</el-button>
        </template>
      </el-table-column>
    </el-table>
      <el-card>
        <el-collapse accordion>
          <el-collapse-item v-for="OReporttm in OReporttmList" :title="OReporttm.checkdate" :name="OReporttm.id" :key="OReporttm.id">
            <template slot="title">
              <span>{{OReporttm.checkdate}} </span>
              <span style="float: right">
                <el-button size="mini" @click="pickeThis(OReporttm)" type="text">pick</el-button>
              </span>
            </template>
            <el-main style="max-height: 300px">
              <showDMS :OReporttm="OReporttm"></showDMS>
            </el-main>
          </el-collapse-item>
        </el-collapse>
      </el-card>
  </section>
</template>

<script>
  import Vue from 'vue'//后续添加属性，需要vue联动
  import errHandler from '@/assets/errHandler.js'
  import showDMS from './showDMS'
  import {mapGetters, mapActions} from 'vuex'
  export default {
    name: "selDMS",
    components:{showDMS},
    props: ['keywords','examineItem'],
    data() {
      return {
        resumeList:[],
        resumePage:0,
        OReporttmList:[],
        currDMS:null,
        showDMSDetail:false
      }
    },
    created(){
      if(this.keywords){
        this.searchResume(this.keywords)
      }else {
        this.resumeList=[]
        this.resumePage=0
      }
    },
    watch:{
      keywords(nv,ov){
        console.log(nv)
        if(nv){
          console.log(nv)
          this.searchResume(this.keywords)
        }else {
          this.resumeList=[]
          this.resumePage=0
        }
      }
    },
    computed:{
      ...mapGetters(['department'])
    },
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      searchResume(keywords){
        this.fetch({name:"searchResume",data:{keywords}})
          .then(res=>{
            console.log(res)
            this.resumeList=res.content
            this.resumePage=res.totalPages
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
      loadingDMS(row){
        console.log(row)
        this.listOReporttm(row.id)
      },
      listOReporttm(resumeId){
        this.fetch({name:"listOReporttm",data:{resumeId}})
          .then(res=>{
            this.OReporttmList=res.content
            console.log(this.OReporttmList)
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
      pickeThis(OReporttm){
        console.log(OReporttm.id)
        // Vue.set(this.examineItem.data,'OReporttm',OReporttm.id)
        this.fetch({name:"docSumExamineItem",data:{id:this.examineItem.id,summary:OReporttm.id,details:OReporttm}})
          .then(res=>{
            console.log(res)
            this.examineItem.summary = res.summary
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      }
    }
  }
</script>

<style scoped>

</style>
